﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Patent.LJ;
using Patent.CN;
using System.Data;
using DevExpress.XtraCharts;

public partial class China_Chart_OrientAreaFullStackedView : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string local = "12,13,22,23,31,42";
        Topic topic = new Topic(Convert.ToInt32(Session["topicID"].ToString()));
        //Patent.LJ.Topic topic = new Patent.LJ.Topic(1);
        string localTable = topic.OriginalTable;//原产区表名

        if (string.IsNullOrEmpty(local))
        {
            Response.End();
            Response.Flush();
        }

        string[] area = local.Split(',');
        ChinaAnalysis ana = new ChinaAnalysis();
        DataTable dt = ana.GetLocalArea(area, localTable);
        for (int i = 0; i < dt.Columns.Count; i++)
        {
            switch (dt.Columns[i].ColumnName)
            {
                case "dm": dt.Columns[i].ColumnName = "国省代码"; break;
                case "sy": dt.Columns[i].ColumnName = "实用新型"; break;
                case "fm": dt.Columns[i].ColumnName = "发明专利"; break;
                case "wg": dt.Columns[i].ColumnName = "外观设计"; break;
                case "zj": dt.Columns[i].ColumnName = "总计"; break;
                default: break;
            }
        }

        WebChartCN.Series.Clear();

        Series syxxSeries = new Series("实用新型", ViewType.FullStackedBar);
        Series fmzlSeries = new Series("发明专利", ViewType.FullStackedBar);
        Series wgsjSeries = new Series("外观设计", ViewType.FullStackedBar);

        WebChartCN.Series.Add(syxxSeries);
        WebChartCN.Series.Add(fmzlSeries);
        WebChartCN.Series.Add(wgsjSeries);

        syxxSeries.ArgumentDataMember = "国省代码";
        syxxSeries.ValueDataMembers.AddRange(new string[] { "实用新型" });

        fmzlSeries.ArgumentDataMember = "国省代码";
        fmzlSeries.ValueDataMembers.AddRange(new string[] { "发明专利" });

        wgsjSeries.ArgumentDataMember = "国省代码";
        wgsjSeries.ValueDataMembers.AddRange(new string[] { "外观设计" });

        foreach (Series series in WebChartCN.Series)
        {
            //series.Label.Visible = false;
            series.DataSource = dt;
            series.ArgumentScaleType = ScaleType.Qualitative;
            series.ValueScaleType = ScaleType.Numerical;

            series.PointOptions.PointView = PointView.Values;
            series.PointOptions.ValueNumericOptions.Format = NumericFormat.Percent;
            series.PointOptions.ValueNumericOptions.Precision = 0;
        }
        // Prevent IE Cache
        Response.Expires = 0;
    }
}
